<template>
	<view class="all">
		<view class="pic">
			<u-swiper radius='0' :list="pageDate.institution_img" @change="e => current = e.current" height="281">
				<view slot="indicator" class="indicator">
					<view class="indicator__dot" v-for="(item, index) in pageDate.institution_img" :key="index"
						:class="[index === current && 'indicator__dot--active']">
					</view>
				</view>
			</u-swiper>
			<view style="height: var(--status-bar-height);opacity: 0;">
				<!-- app状态栏高度占位 -->
			</view>
			<view class="return iconfont" @click="toHome()">
				&#xe601;
			</view>
		</view>
		<view class="roomStyle">
			<view class="line1">
				<image v-if="pageDate.institution_type=='公办'" style="width: 62rpx;height: 36rpx;margin-right: 20rpx;" src="/static/img/icon_public.png" mode=""></image><image v-else style="width: 62rpx;height: 36rpx;margin-right: 20rpx;" src="/static/img/icon_private.png" mode=""></image> {{pageDate.institution_name}}
			</view>
			<view class="line2">
				<view class="left">
					{{pageDate.institution_address}}
				</view>
				<view class="right">
					<view class="icon1">
						<image style="width: 60rpx;height: 60rpx;" src="/static/img/btn_phone.png" mode=""></image>
					</view>
					<view class="icon2" @click="chooselocal(pageDate.institution_address,pageDate.institution_name)">
						<image style="width: 60rpx;height: 60rpx;" src="/static/img/btn_location.png" mode=""></image>
					</view>
				</view>
			</view>
		</view>
		<view class="text">
			{{pageDate.institution_detail}}
		</view>
		<view class="tips">
			<view class="title">
				温馨提示
			</view>
			<view class="content">
				1.养老机构按照老人自愿入院的原则入住。<br>
				2.养老机构可能对老人提供流动服务与呼叫服务相结合。老人及子女若有增项服务，应该与院方协商，取得同意方可使用。<br>
				3.预约成功后，养老机构会收到您的预约信息，请等待工作人员与您联系。<br>
				4.预约成功后，欢迎您按预约时间前往养老院机构参观环境和现场查看房型。
			</view>
		</view>
		<view class="btns">
			<view class="btn" @click="toEditOrg()">
				编 辑
			</view>
		</view>
	</view>
</template>

<script>
	import {getInstitution} from '@/utils/api.js'
	export default {
		data() {
			return {
				current: 0,
				list1: [
					'https://img2.baidu.com/it/u=1430172694,3211689169&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=334',
					'https://img0.baidu.com/it/u=3802054516,1333894234&fm=253&fmt=auto&app=138&f=JPEG?w=750&h=500',
					'https://img1.baidu.com/it/u=2542146708,987117678&fm=253&fmt=auto&app=138&f=JPEG?w=723&h=500'
				],
				pageDate:{},
				latitude: '',
				longitude: ''
			};
		},
		mounted(){
			getInstitution().then((res)=>{
				console.log(res,'++++++++++');
				if(res.data.meta.status==200){
					this.pageDate=res.data.data
					if(res.data.data.length==0){
						this.Institution=false
					}
				}
			})
		},
		methods: {
			toEditOrg(){
				uni.navigateTo({
					url:'/pages/my/organization/organizationEdit?id='+2
				})
			},
			toHome(){
				uni.switchTab({
					url:'/pages/my/my'
				})
			},
			chooselocal(address,name) {
				let data={add:address,name:name}
				uni.request({
					url: 'https://restapi.amap.com/v3/geocode/geo?parameters',
					method: 'GET',
					type: 'gcj02',
					data: {
						key: '44237e1964e1480718c9efbe5d214bed', //高德地图key
						address: address // 详细地址
					},
					success: res => {
						// console.log(res.data.geocodes[0].location)
						const latitude = res.data.geocodes[0].location.split(",")[0];
						const longitude = res.data.geocodes[0].location.split(",")[1];
						this.latitude = latitude
						this.longitude = longitude
						console.log(this.latitude, this.longitude)
						let data = {
							la: this.latitude,
							lo: this.longitude,
							name:name
						}
						uni.navigateTo({
							url:"/pages/my/organization/location1?data="+ encodeURIComponent(JSON.stringify(data))
						})
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.all {
		position: relative;
		
		.indicator {
			@include flex(row);
			justify-content: center;

			&__dot {
				height: 6px;
				width: 6px;
				border-radius: 100px;
				background-color: rgba(255, 255, 255, 0.35);
				margin: 0 5px;
				transition: background-color 0.3s;

				&--active {
					background-color: #ffffff;
				}
			}
		}

		.indicator-num {
			padding: 2px 0;
			background-color: rgba(0, 0, 0, 0.35);
			border-radius: 100px;
			width: 35px;
			@include flex;
			justify-content: center;

			&__text {
				color: #FFFFFF;
				font-size: 12px;
			}
		}

		.pic {

			width: 100%;
			height: 281px;

			.return {
				position: fixed;
				height: 30rpx;
				top: var(--status-bar-height);
				left: 30rpx;
				right: 0;
				bottom: 0;
				color: #ffffff;
				font-size: 24px;

			}
		}
		.roomStyle{
			background-color: #FFFFFF;
			padding: 40rpx 24rpx;
			.line1{
				font-size: 36rpx;
				font-weight: bold;
				color: #242424;
			}
			.line2{
				margin-top: 10rpx;
				display: flex;
				justify-content: space-between;
				.left{
					font-size: 26rpx;
					font-weight: bold;
					color: #686868;
					line-height: 50rpx;
					
				}
				.right{
					display: flex;
					.icon1,.icon2{
						width: 60rpx;
						height: 60rpx;
					}
					.icon1{
						margin-right: 32rpx;
					}
				}
			}
			.describe{
				font-size: 26rpx;
				font-weight: bold;
				color: #484848;
				line-height: 40rpx;
			}
		}
		.text{
			padding: 0 24rpx 43rpx 24rpx;
			background-color: #FFFFFF;
			font-size: 26rpx;
			font-weight: bold;
			color: #484848;
			line-height: 45rpx;
		}
		
		.tips{
			margin-top: 16rpx;
			border-bottom:2rpx solid #f1f7fe;
			background-color: #FFFFFF;
			padding: 40rpx 24rpx;
			.title{
				font-size: 36rpx;
				font-weight: bold;
				color: #242424;
			}
			.content{
				margin-top: 30rpx;
				font-size: 26rpx;
				font-weight: bold;
				color: #686868;
				line-height: 40rpx;
				
			}
		}
		.btns{
			height: 200rpx;
			background: #FFFFFF;
			display: flex;
			justify-content: center;
			align-items: center;
			.btn{
				width: 462rpx;
				height: 88rpx;
				background: #5398F6;
				border-radius: 44rpx;
				text-align: center;
				line-height:88rpx ;
				font-size: 32rpx;
				font-weight: bold;
				color: #FFFFFF;
			}
		}
	}
</style>